home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUT1-9.ZIP / TUTPROG1.PAS < prev    next >
Pascal/Delphi Source File  |  1994-01-11  |  4KB  |  124 lines

  1. {$X+}   (* This is a handy little trick to know. If you put this at the top
  2.            of your program, you do not have to set a variable when calling
  3.            a function, i.e. you may just say 'READKEY' instead of
  4.            'CH:=READKEY'                                                *)
  5.  
  6. USES Crt;           (* This has a few nice functions in it, such as the
  7.                        READKEY command.                                 *)
  8.  
  9. CONST VGA = $a000;  (* This sets the constant VGA to the segment of the
  10.                        VGA screen.                                      *)
  11.  
  12. {──────────────────────────────────────────────────────────────────────────}
  13. Procedure SetMCGA;  { This procedure gets you into 320x200x256 mode. }
  14. BEGIN
  15.   asm
  16.      mov        ax,0013h
  17.      int        10h
  18.   end;
  19. END;
  20.  
  21.  
  22. {──────────────────────────────────────────────────────────────────────────}
  23. Procedure SetText;  { This procedure returns you to text mode.  }
  24. BEGIN
  25.   asm
  26.      mov        ax,0003h
  27.      int        10h
  28.   end;
  29. END;
  30.  
  31.  
  32. {──────────────────────────────────────────────────────────────────────────}
  33. Procedure Cls (Col : Byte);
  34.    { This clears the screen to the specified color }
  35. BEGIN
  36.   Fillchar (Mem [$a000:0],64000,col);
  37. END;
  38.  
  39.  
  40. {──────────────────────────────────────────────────────────────────────────}
  41. Procedure INTPutpixel (X,Y : Integer; Col : Byte);
  42.    { This puts a pixel on the screen using interrupts. }
  43. BEGIN
  44.   asm
  45.      mov        ah,0Ch
  46.      mov        al,[col]
  47.      mov        cx,[x]
  48.      mov        dx,[y]
  49.      mov        bx,[1]
  50.      int        10h
  51.   end;
  52. END;
  53.  
  54.  
  55. {──────────────────────────────────────────────────────────────────────────}
  56. Procedure TestINTPutpixel;
  57.    { This tests out the speed of the INTPutpixel procedure. }
  58. VAR loop1,loop2 : Integer;
  59. BEGIN
  60.   For loop1:=0 to 319 do
  61.     For loop2:=0 to 199 do
  62.       INTPutpixel (loop1,loop2,Random (256));
  63.   Readkey;
  64.   Cls (0);
  65. END;
  66.  
  67.  
  68.  
  69. {──────────────────────────────────────────────────────────────────────────}
  70. Procedure MEMPutpixel (X,Y : Integer; Col : Byte);
  71.   { This puts a pixel on the screen by writing directly to memory. }
  72. BEGIN
  73.   Mem [VGA:X+(Y*320)]:=Col;
  74. END;
  75.  
  76.  
  77. {──────────────────────────────────────────────────────────────────────────}
  78. Procedure TestMEMPutpixel;
  79.    { This tests out the speed of the MEMPutpixel procedure. }
  80. VAR loop1,loop2 : Integer;
  81. BEGIN
  82.   For loop1:=0 to 319 do
  83.     For loop2:=0 to 199 do
  84.       MEMPutpixel (loop1,loop2,Random (256));
  85.   Readkey;
  86.   Cls (0);
  87. END;
  88.  
  89.  
  90.  
  91. {──────────────────────────────────────────────────────────────────────────}
  92. BEGIN    (* Of the main program *)
  93.   ClrScr;               { This clears the text Screen (CRT unit) }
  94.   Writeln ('What will happen is that I will clear the screen twice. After');
  95.   Writeln ('each clear screen you will have to hit a key. I will then fill');
  96.   Writeln ('the screen twice with randomlly colored pixels using two different');
  97.   Writeln ('methoods, after each of which you will have to hit a key. I will');
  98.   Writeln ('then return you to text mode.');
  99.   Writeln; Writeln;
  100.   Write ('Hit any kay to continue ...');
  101.   Readkey;
  102.  
  103.   SetMCGA;
  104.   CLS (32);
  105.   Readkey;
  106.   CLS (90);
  107.   Readkey;
  108.   TestINTPutpixel;
  109.   TestMEMPutpixel;
  110.   SetText;
  111.  
  112.   Writeln ('All done. This concludes the first sample program in the ASPHYXIA');
  113.   Writeln ('Training series. You may reach DENTHOR under the name of GRANT');
  114.   Writeln ('SMITH on the MailBox BBS, or leave a message to ASPHYXIA on the');
  115.   Writeln ('ASPHYXIA BBS. Get the numbers from Roblist, or write to :');
  116.   Writeln ('             Grant Smith');
  117.   Writeln ('             P.O. Box 270');
  118.   Writeln ('             Kloof');
  119.   Writeln ('             3640');
  120.   Writeln ('I hope to hear from you soon!');
  121.   Writeln; Writeln;
  122.   Write   ('Hit any key to exit ...');
  123.   Readkey;
  124. END.     (* Of the main program *)